package com.tz.web.book;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.tz.bean.TzParams;
import com.tz.service.user.IUserService;
import com.tz.util.TmStringUtils;

@Controller
@RequestMapping("/stage")
public class SRegestController {
	
	@Autowired
	private IUserService userService;
	
	@ResponseBody//ajax提交必须写这个不然不会在进入ajax的success函数
	@RequestMapping(value="/regested",method=RequestMethod.POST)
	public String regested(TzParams params){
		int number;
		if(params!=null){
			if(TmStringUtils.isNotEmpty(params.getAccount())&&TmStringUtils.isNotEmpty(params.getPassword())){
				number = userService.add(params);
				if(number<0){
					return "success";
				}else {
					return "fail";
				}
			}else {
				return "fail";
			}
		}else {
			return "errol";
		}
	}
}
